package com.xinghanlaser.applet.service.impl;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xinghanlaser.applet.entity.TopicHandleHistory;
import com.xinghanlaser.applet.mapper.TopicHandleHistoryMapper;
import com.xinghanlaser.applet.service.ITopicHandleHistoryService;
import org.springframework.stereotype.Service;

/**
* @author XH-YF-TSDN-0080
* @description 针对表【topic_handle_history】的数据库操作Service实现
* @createDate 2024-05-09 11:47:17
*/
@Service
public class TopicHandleHistoryServiceImpl extends ServiceImpl<TopicHandleHistoryMapper, TopicHandleHistory>
    implements ITopicHandleHistoryService {

    @Override
    public void saveHistory(Long handleDetailId, Long currentPointId, String stepDesc, String handlerDesc) {
        TopicHandleHistory historyEntity = new TopicHandleHistory();
        historyEntity.setHandleId(handleDetailId);
        historyEntity.setCurrentPointId(currentPointId);
        int count = this.count(Wrappers.lambdaQuery(new TopicHandleHistory()).eq(TopicHandleHistory::getHandleId, handleDetailId));
        historyEntity.setStep(count);
        historyEntity.setCreateTime(DateUtil.now());
        historyEntity.setStepDesc(stepDesc);
        historyEntity.setHandlerDesc(handlerDesc);

        this.save(historyEntity);
    }
}




